package com.spzx.product.api;

import com.spzx.common.core.constant.SecurityConstants;
import com.spzx.common.core.domain.R;
import com.spzx.product.api.domain.vo.CategoryNestedVo;
import com.spzx.product.api.domain.vo.CategoryVo;
import com.spzx.product.api.factory.RemoteCategoryFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import com.spzx.common.core.constant.ServiceNameConstants;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;

import java.util.List;

/**
 * @author Haoran Sun
 * @since 2024/07/23
 */

@FeignClient(
        contextId = "remoteCategoryService",
        value = ServiceNameConstants.PRODUCT_SERVICE,
        fallbackFactory = RemoteCategoryFallbackFactory.class
)
public interface RemoteCategoryService {
    /**
     * 获取一级分类列表
     * @param source 源-验证是否为内部调用
     * @return 一级分类列表
     */
    @GetMapping(value = "/category/getOneCategory")
    R<List<CategoryVo>> getOneCategory(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 获取分类树
     * @param source 源-验证是否为内部调用
     * @return 分类树
     */
    @GetMapping(value = "/category/tree")
    R<List<CategoryNestedVo>> tree(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}
